package com.swotxu.mall.member.exception;

import com.swotxu.common.exception.BizCodeEnum;

/**
 * 校验重复异常
 *
 * @Date: 2021/2/17 19:33
 * @Author: swotXu
 */
public abstract class ExistException extends RuntimeException {

    public ExistException(String message) {
        super(message);
    }

    public abstract BizCodeEnum getType();

    public static class UsernameExistException extends ExistException {
        public UsernameExistException() {
            super("用户名存在");
        }

        @Override
        public BizCodeEnum getType() {
            return BizCodeEnum.USER_EXIST_EXCEPTION;
        }
    }

    public static class MobileExistException extends ExistException {
        public MobileExistException() {
            super("手机号存在");
        }

        @Override
        public BizCodeEnum getType() {
            return BizCodeEnum.MOBILE_EXIST_EXCEPTION;
        }
    }

    public static class EmailExistException extends ExistException {
        public EmailExistException() {
            super("邮箱存在");
        }

        @Override
        public BizCodeEnum getType() {
            return BizCodeEnum.EMAIL_EXIST_EXCEPTION;
        }
    }
}
